//SampleDll.cpp
//

#include <windows.h>
#include "stdafx.h"
#define EXPORTING_DLL
#include "SVGExsample.h"
#include "SVGDrawing.h"
using namespace std;
BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    return TRUE;
}
/*
 *draw a house:roof, door and window
 *The x defines the left position of the house
 *The y defines the top position of the house
 *The width and height define the height and the width of the house
*/
void draw(int x, int y, int width, int height)
{
	if(x<0 || y<0 || width<=0 || height<=0)
	{
		cerr<<"Error in draw function: x, y, width, height must greater than null"<<endl;
		exit(1);
	}
	SVGDrawing test;
	
	//create roof
	//hRoof defines the height of the roof
	//x,y defines the position of the roof
	int hRoof = height*0.25;	
	int xRoof = x+width/2;
	int yRoof = y+hRoof;	
	test.createLine(x, yRoof, xRoof, y);
	test.createLine(xRoof , y, x+width, yRoof);
	//create room
	int hRoom = height-hRoof;
	test.createRect(x, yRoof, width, hRoom);
	//create door
	//xDoor, yDoor define the position of the door
	//wDoor defines the width of the door and hDoor defines the height of the door 
	int xDoor = x + width*0.375;
	int yDoor = yRoof + height*0.5;
	int wDoor = width*0.2;
	int hDoor = height*0.25;
	test.createRect(xDoor, yDoor, wDoor, hDoor);
	//create window
	//xWindow, yWindow define the position of the window
	//wWindow defines the width of the window and hWindow defines the height of the window 
	int xWindow = x + width*0.35;
	int yWindow = yRoof + height*0.15;
	int wWindow = width*0.3;
	int hWindow = height*0.15;
	test.createRect(xWindow, yWindow, wWindow, hWindow);
	test.saveToFile(".//house.svg");
}
/*
void drawRoof(const SVGDrawing &rt, const int x, const int y, const int width, const int height)
{
	int y1 = y-width/2;
	if (y1<0)
	{
		cerr<<"Error: y-axis must greater than null";
		exit(1);
	}
	int x1 = x+width/2;
	rt.createLine(x, y, x1, y1);
	rt.createLine(x1 , y1, x+width, y);
	rt.createRect(x, y, width, height-y1);
}
*/
/*
void drawRoom(const SVGDrawing &rt, const int x, const int y, const int width, const int height)
{
	rt.createRect(x, y, width, height-width/2);
}
*/
